	var titlearr = ["topic","time","value"];
	var titleName = ["消息类型","消费时间","Kafka数据"];
	
	function fullTitle() {
		var thHtml = '<thead><tr>';
		titleName.forEach(function (key) {
			thHtml += '<th>'+key+'</ th>';
		});
		thHtml += '</ tr></ thead>';
  		tBodyHtml = '<tbody id="tbody">';
  		tBodyHtml += '</ tbody>';
  		$('#dt_basic').append(thHtml+tBodyHtml);
  		$('#loading').show();
		$.ajax({
			"url" : "/smarttest-frontstage/kafka/getTopic.action",
			dataType : 'json',
		  	method:'GET',
		  	success:function(data){
		  		var result = data.result ;
		  		if (result == 0){
		  			var topics = data.topics;
		  			var option = '';
		  			option += '<option value="all">全部</option>';
		  			topics.forEach(function (key){
		  				option += '<option value="'+key+'">'+key+'</option>';
		  			});
		  			$("#topic_sel").html('');
		  			$("#topic_sel").html(option);
		  			doSearch();
		  		}
		  		$('#loading').hide();
		  	}
		});
	}
	function doSearch(){
 		$("#doSearch").click(function () {
 			unBindPage();//当再次点击搜素时，就会再次运行一个pageChange函数
 			toPage = 1 ;
 			searchBy();
 			pageChange();
 		});
	} 
	
	
	function searchBy(){
		$('#loading').show();
		var dataType = $("#data_type").val();
		var uncodeData = $("#imei").val();
		var data = encodeURI(encodeURI(uncodeData));
		var start = $("#starttime").val();
		var end = $("#endtime").val();
		var pageSize = $('#dt_row').val();
		var topage = toPage;
		var reversed = $("#reversed").val();
		var topic = $("#topic_sel").val();
		
		var url = "/smarttest-frontstage/kafka/getData.action?data="+data+"&topic="+topic+"&start="+
			start+"&end="+end+"&toPage="+topage+"&pageSize="+pageSize+"&dataType="+dataType+"&reversed="+reversed;
		
		$.ajax({
			"url" : url,
			dataType : 'json',
		  	method:'GET',
		  	success:function(data){
		  		$('.dataTables_info').html('');
				$('#tbody').html('');
		  		var result = data.result;
		  		if (result == 0){
		  			showData(data);
		  		}
		  		$('#loading').hide();
		  	}
		});
	}
	
	function showData(data) {
		totalCloums = data.total;
		if (totalCloums > 0){
			var pageSize = $('#dt_row').val();
	  		totalpage = Math.ceil(totalCloums/pageSize);
	  		totalpage = totalpage<=0?1:totalpage ;
	  		
  			var item = data.rows;
	  		var tdHtml = '';
	  		item.forEach(function (row){
	  			tdHtml += '<tr>';
	  			titlearr.forEach(function(key){
	  				if (row[key] == null){
	  					tdHtml += '<td></ td>';
	  				}else{
	  				tdHtml += '<td>'+row[key]+'</ td>';
	  				}
	  			});
	  			tdHtml += '</ tr>';
	  		});
	  		//$('#tbody').html('');
	  		$('#tbody').append(tdHtml);
	  		
	  		if($("#ofix3_div_head") != []){
	  			$("#ofix3_div_head").remove();
	  		}
	  		var ofix1 = new oFixedTable('ofix3', document.getElementById('dt_basic'), {rows:1});
	  		
	  		$("#dt_basic").freezeHeader();
	  		var infoHtml = '当前第'+toPage+'页 ';
	  		var from = pageSize*(toPage-1)+1;
	  		var to = pageSize*toPage;
	  		infoHtml += ' 从 '+from+' 到 '+to+' / 共 '+totalCloums+' 条数据';
	  		
	  		$('.dataTables_info').html(infoHtml);
		}
	}

	
	function pageChange(){
		$(".prev").click(function () {
 			if (toPage > 1){
 				toPage--;
 				searchBy();
 			}
	 });
	$(".next").click(function () {
		if (toPage < totalpage){
 			toPage++;
 			searchBy();
 		} else {
 			showEndInfo();
 		}
	 });
	$("#dt_row").change(function () {
		if ($("#selectTable").find("option:selected").attr('class') == "from_hBase"){
			toPage = 1;
		} else {
			var pageSize = $('#dt_row').val();
	  		totalpage = Math.ceil(totalCloums/pageSize);
	  		totalpage = totalpage<=0?1:totalpage ;
			if (totalpage < toPage) {
				toPage = totalpage ;
			}
		}
		searchBy();
	});
	}
	
	function unBindPage(){
		$(".prev").unbind();
		$(".next").unbind();
		$("#dt_row").unbind();
	}
	

	function showEndInfo () {
		$('#reach_end').show();
		setTimeout("$('#reach_end').hide();",3000);
	}
	
